﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Child_In_Law : RelationBase
    {
        private static Child_In_Law _singleton = new Child_In_Law();
        public static Child_In_Law Instance
        {
            get { return _singleton; }
        }

        private Child_In_Law() { }

        public override bool IsRelated(Person a, Person b)
        {
            // problem: parents are being concluded to be child-in-laws
            // a = Rosario
            // b = Rich
            // b is a's Child_In_Law IFF b is the spouse of a's child AND a is NOT b's parent
            return a.KnownRelation(Child.Instance, b.Spouse) &&
                !(b.Mother == a || b.Father == a);
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] {
                Spouse.Instance, Child.Instance, Mother.Instance, Father.Instance });
        }
    }
}
